package com.quanquan.store.repository;

import com.quanquan.store.entity.Label;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @ClassName:LabelRepository
 * @Description:TODO
 * @Author:xiongjunbao
 * @Date:2019/7/19 13:53
 * @Version 1.0
 */
public interface LabelRepository extends JpaRepository<Label, String> {

    /**
     * 查看标签详情
     *
     * @param id
     * @return
     */
    @Query(value = "select * from oo_label where status_remove = 0 and id = ?1", nativeQuery = true)
    Label findbyLabelId(String id);

    /**
     * 查看所有的有效的标签
     *
     * @return
     */
    @Query(value = "select * from oo_label where status_show = 0 and status_remove = 0 order by sort_order asc limit ?1,?2", nativeQuery = true)
    List<Label> findAllLabel(Integer count, Integer size);

}
